<?php

/**
 * katalog_anlegen Php Datei zum anlegen eines neuen Produktkataloges.
 * @package Katalog
 * @author Jens Albrecht
 * @copyright 2012 Jens Albrech
 */

require_once './class.SQLConfig.php';
include_once './class.SQLConfig.php';

$name = $_POST["Name"];
$beschreibung = $_POST["Beschreibung"];
$design = $_POST["Design"];
$IDs = $_POST["ProduktIDs"];


$Conn = new SQLConfig();

$Conn->Query="Insert into tbl_Kataloge(Name,Design,beschreibung) Values('$name','$design','$beschreibung')";

$erg = $Conn->Get_Data();

if($erg <>""){
    echo "$erg";
}

$Conn->Query="Select MAX(ID) from tbl_Kataloge";

$erg2 = $Conn->Get_Data();

$Produkte = preg_split('/ /', $IDs, -1, PREG_SPLIT_NO_EMPTY);

foreach ($Produkte as $Nummer) {

    $Conn->Query="Insert into tbl_Katalog_Produkte(KatalogID,ProduktID) Values('$erg2[0]','$Nummer')";

    $erg3 = $Conn->Get_Data();

    if($erg3 <>""){
        echo "$erg";
    }
}
header("Location:../katalog.php");
?>
